package com.woniuxy.thred;

/**
 * description: LambdaTest01 <br>
 * date: 2022/2/5 4:29 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */
public class LambdaTest01 {
    //静态内部类
    static class Like2 implements ILike {
        @Override
        public void Lambda() {
            System.out.println("i like lambda!");
        }
    }

    public static void main(String[] args) {
        ILike iLike = new Like();
        iLike.Lambda();
        iLike = new Like2();
        iLike.Lambda();

        class Like3 implements ILike {
            @Override
            public void Lambda() {
                System.out.println("i like lambda3!");
            }
        }

        iLike = new Like3();
        iLike.Lambda();
        //匿名内部类
        iLike = new ILike() {
            @Override
            public void Lambda() {
                System.out.println("i like lambda4!");
            }
        };
        iLike.Lambda();
        //lambda表达式
        iLike = () -> {
            System.out.println("i like lambda5!");
        };
        iLike.Lambda();
    }
}

interface ILike {
    void Lambda();
}

//外部类
class Like implements ILike {
    @Override
    public void Lambda() {
        System.out.println("i like lambda1!");
    }
}